<template>
  <view>
  <view   v-for="(item,index) in list"  :key="index">
    
    <view class="list-line-item" v-if="item.jumpType==1||item.jumpType==2"  @click="jumpPage" :data-jumpUrl="item.jumpUrl" :data-jumpType="item.jumpType" >
      
      <view class="list-line-item-text">
        {{item.name}}
      </view>
      <text class="cuIcon-right base-font-28 text-B2"></text>
    </view>
    <view  v-else-if="item.jumpType==3">
      <button open-type="contact" class="cs_button">
      <view class="list-line-item">
      
        <view class="list-line-item-text">
          {{item.name}}
        </view>
          <text class="cuIcon-right base-font-28 text-B2" >
          </text>
      </view>
      </button>
    </view>
    
    <view class="list-line-item" v-else-if="item.jumpType==4"  @click="callPhone" :data-phone="item.jumpUrl">

      <view class="list-line-item-text">
        {{item.name}}
      </view>
      <text class="cuIcon-right base-font-28 text-B2"></text>
    </view>
    
  </view>
  </view>
</template>
<script>
  export default{
    data(){
      return {
        list:[],
      }
    },
    props:{
		//审核类型：1、不审核，2、审核不通过，弹窗提示，3、审核不通过，跳转页面
		checkType:{
		  type:String,
		  default(){
		    return "1"
		  }
		},
		checkPage:{
		  type:String,
		  default(){
		    return "/pages/my/my"
		  }
		},
      myList:{
        type:Array
      }
    },
    mounted() {
      this.list=this.myList;
    },
    watch: {
      myList:{
        handler(newValue, oldValue) {  
          this.list=newValue;
		  var _wxBtnList=newValue;
		  if(_wxBtnList){
		  	this.list=new Array();
		  	_wxBtnList.forEach(e=>{
		  	  this.list.push({name:e.name,icon:e.files,jumpType:e.operateType,jumpUrl:e.operateParams});
		    });
		  }
        },
        deep:true
      }
    },
    methods:{
      callPhone(e){
        var phone=e.currentTarget.dataset.phone;
        uni.makePhoneCall({
            phoneNumber: phone
          });
      },
		jumpPage(e) {
				let type=true;
				if(this.checkType!="1"){
					//验证
					let token=uni.getStorageSync('token');
					if(token==null||token==""){
						type=false;
					}
				}
				if(type){
					var jumpType=e.currentTarget.dataset.jumptype;
					var jumpurl=e.currentTarget.dataset.jumpurl;
					if(jumpurl!=null&&jumpurl!=""){
					  if(jumpType==1){
					   uni.redirectTo({
					   	url:jumpurl,
					   })
					  }else{
					    uni.navigateTo({
					    	url:jumpurl,
					    })
					  }
					}
				}else if(this.checkType=="2"){
					uni.showModal({
						title: '',
						content:'请先登录/注册',
					    showCancel:false,
						success: function(res) {
						}
					});
				}else if(this.checkType=="3"){
					uni.redirectTo({
						url:this.jumpPage,
					})
				}
		}
     
    }
  }
  
</script>


<style>
  .content {
  		position: relative;
  	}
  .list-line-item{width:100%;flex-wrap:nowrap; display:flex; padding: 30upx 0upx;}
  .list-line-item .list-line-item-icon{width:40upx; height: 40upx; margin:0upx 20upx; }
  .list-line-item .list-line-item-icon image{width:40upx;height: 40upx; flex-shrink:0;}
  .list-line-item .list-line-item-text{width:100%; height:40upx;line-height: 40upx;font-size:30upx; color: #666666; }
  .list-line-item+.list-line-item{border-top:1upx solid #EEEEEE;}
  .cs_button {
    background-color: #fff;
    border: 0px;
    padding-left: 0px;
    padding-right: 0px;
    line-height:40upx;
    color:#2F2F2F;
    text-align:left;
    font-size:28upx;
    background-color:#ffffff;
  }
  .cs_button:after {
    border: 0px;
  }

</style>